package tazadum.engine.event.sync;

import tazadum.engine.event.SyncEventChannel;

public class PulseSyncEvent implements SyncEvent {
	private final SyncEventChannel channel;
	private float lastEvent = 0;

	public PulseSyncEvent(final SyncEventChannel channel) {
		this.channel = channel;
		this.lastEvent = channel.get(0);
	}

	@Override
	public float evaluate(final float time) {
		final float event = channel.get(time);
		if (event > lastEvent || event < lastEvent) {
			lastEvent = event;
			return 1f;
		}
		return 0f;
	}
}
